<include file="Public/min-header" />
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<div class="wrapper">
    <include file="Public/breadcrumb" />
    <section class="content ">
        <div class="container-fluid">
            <div class="pull-right">
                <a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-list"></i> 添加拼团活动</h3>
                </div>
                <div class="panel-body ">
                    <form method="post" id="handleposition" action="{:U('Admin/Promotion/fightGroupHandle')}">
                        <div class="tab-content col-md-10">
                            <div class="tab-pane active" id="tab_tongyong">
                                <table class="table table-bordered">
                                    <tbody>
                                        <tr>
                                            <td class="col-sm-2 text-right">拼团标题：</td>
                                            <td class="col-sm-6">
                                                <input type="text" class="form-control" name="title" id="title" value="{$info.title}">
                                                <span id="err_attr_name" style="color:#F00; display:none;"></span>
                                            </td>
                                            <td class="col-sm-4">请填写拼团标题</td>
                                        </tr>
                                        <tr>
                                            <td class = "text-right">开始时间：</td>
                                            <td>
                                                <input type="text" class="form-control" id="start_time" name="start_time" value="{$info.start_time}">
                                            </td>
                                            <td class="col-sm-4">拼团开始时间</td>
                                        </tr>
                                        <tr>
                                            <td class = "text-right">结束时间：</td>
                                            <td>
                                                <input type="text" class="form-control" id="end_time" name="end_time" value="{$info.end_time}">
                                            </td>
                                            <td class="col-sm-4">拼团结束时间</td>
                                        </tr>
                                        <tr>
                                            <td class = "text-right">设置拼团商品：</td>
                                            <td>
                                                <div class="col-xs-9 clear-padding">
                                                    <input type="text" id="goods_name" name="goods_name" class="form-control" value="{$info.goods_name}">
                                                </div>
                                                <div class="col-xs-3">
                                                    <input type="hidden" id="goods_id" name="goods_id" value="{$info.goods_id}">
                                                    <input class="btn btn-primary" type="button" onclick="selectGoods()" value="选择商品">
                                                </div>
                                            </td>
                                            <td class="col-sm-4">请选择加入拼团的商品</td>
                                        </tr>
                                        <tr>
                                            <td class = "text-right">拼团价格：</td>
                                            <td>
                                                <div class="col-xs-4 clear-padding">
                                                    <input type="text" class="form-control" id="price" name="price" value="{$info.price}" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" onkeyup="this.value = this.value.replace(/[^\d.]/g, '')" />
                                                    <input type="hidden" id="goods_price" name="goods_price" value="{$info.goods_price}">
                                                </div>
                                                <span id="price_html"></span>
                                            </td>
                                            <td class="col-sm-4">商品拼团价格</td>
                                        </tr>
                                        <tr>
                                            <td class = "text-right">拼团数量：</td>
                                            <td>
                                                <input type="text" class="form-control" id="several_group" name="several_group" value="{$info.several_group}" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value = this.value.replace(/[^\d]/g, '')" />
                                            </td>
                                            <td class="col-sm-4">请填写自然数，几人团</td>
                                        </tr>
                                        <tr>
                                            <td class = "text-right">参团数量：</td>
                                            <td>
                                                <input type="text" class="form-control" id="goods_num" name="goods_num" value="{$info.goods_num}" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value = this.value.replace(/[^\d]/g, '')" />
                                            </td>
                                            <td class="col-sm-4">请填写自然数，参与拼团的商品数量</td>
                                        </tr>
                                        <tr>
                                            <td class = "text-right">虚拟购买数：</td>
                                            <td>
                                                <input type="text" class="form-control" name="virtual_num" value="{$info.virtual_num}" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value = this.value.replace(/[^\d]/g, '')" />
                                            </td>
                                            <td class="col-sm-4">虚拟已购买参团人数</td>
                                        </tr>
                                        <tr>
                                            <td class = "text-right">拼团介绍：</td>
                                            <td>
                                                <textarea class="form-control" rows="4" placeholder="请输入拼团介绍" name="intro">{$info.intro}</textarea>
                                            </td>
                                            <td class="col-sm-4">拼团描述介绍</td>
                                        </tr>
                                    </tbody>
                                    <tfoot>
                                        <tr>
                                            <td>
                                                <input class="btn btn-default" type="reset" value="重置">
                                                <input type="hidden" name="act" value="{$act}">
                                                <input type="hidden" name="id" value="{$info.id}">
                                            </td>
                                            <td class="col-sm-4"></td>
                                            <td class="text-right">
                                                <input class="btn btn-primary" type="button" onclick="adsubmit()" value="保存">
                                            </td>
                                        </tr>
                                    </tfoot>
                                </table>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </section>
</div>
<script>
    function adsubmit() {
        if ($('#title').val() == '') {
            layer.msg('拼团标题不能为空');
            return;
        }
        if ($('#price').val() == '') {
            layer.msg('拼团价格不能为空');
            return;
        }
        if ($('#group_num').val() == '') {
            layer.msg('限购数量不能为空');
            return;
        }
        $('#handleposition').submit();
    }

    $(document).ready(function () {
        $('#start_time').daterangepicker({
            format: "YYYY-MM-DD HH:mm:ss",
            singleDatePicker: true,
            showDropdowns: true,
            minDate: '{$min_date}',
            maxDate: '2030-01-01',
            startDate: '{$min_date}',
            timePicker: true, //是否显示小时和分钟  
            timePickerIncrement: 1, //time选择递增数
            timePicker12Hour: false, //是否使用12小时制来显示时间           
            locale: {
                applyLabel: '确定',
                cancelLabel: '取消',
                fromLabel: '起始时间',
                toLabel: '结束时间',
                customRangeLabel: '自定义',
                daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
                firstDay: 1
            }
        });

        $('#end_time').daterangepicker({
            format: "YYYY-MM-DD HH:mm:ss",
            singleDatePicker: true,
            showDropdowns: true,
            minDate: '{$min_date}',
            maxDate: '2030-01-01',
            startDate: '{$min_date}',
            timePicker: true, //是否显示小时和分钟  
            timePickerIncrement: 1, //time选择递增数
            timePicker12Hour: false, //是否使用12小时制来显示时间       
            locale: {
                applyLabel: '确定',
                cancelLabel: '取消',
                fromLabel: '起始时间',
                toLabel: '结束时间',
                customRangeLabel: '自定义',
                daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
                firstDay: 1
            }
        });

    });

    function selectGoods() {
        var url = "{:U('Promotion/searchGoods',array('tpl'=>'selectGoods'))}";
        layer.open({
            type: 2,
            title: '选择商品',
            shadeClose: true,
            shade: 0.2,
            area: ['75%', '75%'],
            content: url,
        });
    }

    function call_back(goods_id, goods_name, store_count) {
        $('#goods_id').val(goods_id);
        $('#goods_name').val(goods_name);
        $('#group_num').val(store_count);
        layer.closeAll('iframe');
    }
</script>
</body>

</html>
